//
//  BaseTabbarViewController.swift
//  jiaoyi
//
//  Created by wjk on 2018/8/1.
//  Copyright © 2018年 wjk. All rights reserved.
//

import UIKit

class BaseTabbarViewController: UITabBarController {

    override func viewDidLoad() {
        
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        NotificationCenter.default.addObserver(self, selector: #selector(tokenOutOfDate), name: NSNotification.Name.TokenOutOfDate, object: nil)
        
        //todo 这里不需要强制登录，只有当需要用户权限的时候，才要登录
        if (UIApplication.shared.delegate as! AppDelegate).isplayData.count > 0 {
            NetWorkManager.shared.checkToken()
        }
        
    }

    @objc func tokenOutOfDate(){
        UserDefaults.User.set(false, forKey: .isLogin)
        
        
        let vc = R.storyboard.login.loginViewController()!

//        (self.selectedViewController as! UINavigationController).pushViewController(vc, animated: true)
        
        UIApplication.shared.delegate?.window?!.rootViewController = R.storyboard.login().instantiateInitialViewController()

//        present(vc, animated: false, completion: nil)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
